import request from '@/config/axios'

// ERP 采购入库 VO
export interface PurchaseAdviceVO {
  /**
   * 封面
   */
  cover?: string;
  /**
   * 商品采购建议id
   */
  id: number;
  /**
   * 在途库存
   */
  inTransitStock?: number;
  /**
   * 是否主商品  1主 2副
   */
  mainType?: number;
  /**
   * 实际库存
   */
  onHandInventory?: number;
  /**
   * 订单占用数
   */
  orderOccupancyCount?: number;
  productCode?: string;
  /**
   * 商品id
   */
  productId?: string;
  /**
   * 商品名称
   */
  productName?: string;
  /**
   * 商品链接信息
   */
  productPurchaseRespVOList?: ProductPurchaseRespVO[];
  /**
   * 采购建议
   */
  productSuggestions?: string;
  /**
   * 属性
   */
  property?: string;
  /**
   * sku码
   */
  sku?: string;
  /**
   * 未审核在途库存
   */
  unreviewedInTransitInventory?: number;
  [property: string]: any;
}

/**
 * ProductPurchaseRespVO，管理后台 - 商品采购链接 Response VO
 */
export interface ProductPurchaseRespVO {
  /**
   * 创建时间
   */
  createTime: Date;
  /**
   * 主键id
   */
  id: number;
  /**
   * 商品id
   */
  productId?: string;
  /**
   * 备注
   */
  remark?: string;
  /**
   * 采购链接
   */
  url?: string;
  [property: string]: any;
}



// ERP 采购入库 API
export const PurchaseAdviceApi = {
  // 查询采购入库分页
  getPurchaseAdvicePage: async (params: any) => {
    return await request.get({ url: `/admin-api/product/purchase-suggest/page`, params })
  },

  // 查询采购入库详情
  getPurchaseIn: async (id: number) => {
    return await request.get({ url: `/erp/purchase-in/get?id=` + id })
  },

  // 新增采购入库
  createPurchaseIn: async (data: PurchaseInVO) => {
    return await request.post({ url: `/erp/purchase-in/create`, data })
  },

  // 修改采购入库
  updatePurchaseIn: async (data: PurchaseInVO) => {
    return await request.put({ url: `/erp/purchase-in/update`, data })
  },

  // 更新采购入库的状态
  updatePurchaseInStatus: async (id: number, status: number) => {
    return await request.put({
      url: `/erp/purchase-in/update-status`,
      params: {
        id,
        status
      }
    })
  },

  // 删除采购入库
  deletePurchaseIn: async (ids: number[]) => {
    return await request.delete({
      url: `/erp/purchase-in/delete`,
      params: {
        ids: ids.join(',')
      }
    })
  },

  // 导出采购入库 Excel
  exportPurchaseIn: async (params: any) => {
    return await request.download({ url: `/erp/purchase-in/export-excel`, params })
  }
}
